package com.zhang.demo.json;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.net.URISyntaxException;
import java.net.URL;

public class JsonPrarseChild {


    public static void main(String[] args) throws FileNotFoundException, URISyntaxException {
        URL url = JsonPrarseChild.class.getClassLoader().getResource("child.txt");
        File file = new File(url.toURI());
        JsonParser parse =new JsonParser();  //创建json解析器
        JsonObject json=(JsonObject) parse.parse(new FileReader(file));

        System.out.println(json);
        JsonArray children = json.getAsJsonArray("children");

        for (int i = 0; i < children.size(); i++) {

        }

        System.out.println(children);

    }
}
